#include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "tsl2561.h"
#include "usmart.h"
#include "opt3001.h"
#include "oled.h"
#include "iic_soft.h"
#include "app.h"
#include "MPU6050.h"




char show_buff[20];

float lux;

	//LED状态设置函数
void led_set(u8 sta)
{
	LED0=sta;
} 
//函数参数调用测试函数
void test_fun(void(*ledset)(u8),u8 sta)
{
	ledset(sta);
}  	

int main(void)
{ 
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// 设置中断优先级分组2
	delay_init();	    	 //延时函数初始化	  
	uart_init(115200);	 	//串口初始化为9600
	LED_Init();				//初始化与LED连接的硬件接口
	//printf("Init...\r\n");
	usmart_dev.init(72); 	//初始化USMART		
	OLED_Init();
	
	
	// opt3001_init(IIC2,OPT3001_ADDR4);
	 //opt3001_init(IIC0,OPT3001_ADDR1);
	 //u16 id = read_manufacturer_id();
	 //printf("m_id : %#X\r\n",id);
 	// id = read_devid();
	// printf("dev_id : %#X\r\n",id);

	//delay_ms(1000);	
	//IIC_SCAN(IIC2,OPT3001_ADDR4);
	//IIC_SCAN(IIC0,OPT3001_ADDR1);
	//sensor_scan();
	//opt_live_watch();
	MPU6050_Init();
while(1) 
	{	 
	   //Read_MPU6050(&accel,&gyro,&posture);
		//lux=calculate_lux(IIC0,OPT3001_ADDR1);
		//printf("L 0 1:%.3f\r\n",lux);
		//lux=calculate_lux(IIC2,OPT3001_ADDR4);
		//printf("L 2 4:%.3f\r\n",lux);


		//sprintf(show_buff,"x:%.1f  ",posture.x);
		//OLED_ShowString(0,0,show_buff,16);
		//sprintf(show_buff,"y:%.1f  ",posture.y);
		//OLED_ShowString(0,2,show_buff,16);
		
		//printf("posture:%.3f,%.3f\r\n",posture.x,posture.y);
		
		LED0=!LED0;					 
		delay_ms(100);	
	}											    
}	


